package com.khalil.kkadmin.ai.rag.knowledgeset.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.annotation.JSONType;
import com.khalil.kkadmin.infrastructure.jpa.domain.EntityBase;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners(AuditingEntityListener.class)
@Table(name = "rag_knowledge_text")
@Entity
@EqualsAndHashCode(callSuper = true)
@Data
public class RagKnowledgeText extends EntityBase<Long> {
    private Long knowledgeSetId;

    @Column(length = 1024)
    private String title;

    @Column(columnDefinition = "text")
    private String metadata;

    @Column(columnDefinition = "text")
    private String text;

    @Enumerated(EnumType.STRING)
    private SourceEnum source; // 来源

    @Column(name = "rag_document_id")
    private Long ragDocumentId;

    public enum SourceEnum {
        FILE,
        TEXT;

        @JSONField(serialize = false)
        private String value;
    }
}
